package com.digua.tank;

import java.util.Random;

/**
 * @author wangdigua
 * @title 测试Frame
 * @date 2020/11/7 10:10 上午
 * @since 1.0.0
 */
public class Main {


    public static void main(String[] args) throws InterruptedException {
        final TankFrame tankFrame = new TankFrame();
        final int initTankCount = Integer.parseInt(PropertyMgr.get("initTankCount"));
        new Thread(new Runnable() {
            public void run() {
                while (true) {
                    if (tankFrame.tanks.size() >= initTankCount) {
                        try {
                            Thread.sleep(10);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                        continue;
                    }
                    Random random = new Random();
                    //初始化敌方坦克
                    for (int i = 0; i < initTankCount - tankFrame.tanks.size(); i++) {
                        int x = (int) (random.nextInt(100) * (Math.random() * 10));
                        int y = (int) (random.nextInt(100) * (Math.random() * 10));
                        tankFrame.tanks.add(new Tank(x,y,Dir.DOWN,tankFrame,Group.BAD));
                    }
                }
            }
        }).start();

        while (true) {
            Thread.sleep(50);
            tankFrame.repaint();
        }
    }

}
